package com.six.work.mapper;

import com.six.work.entity.Admin;
import com.six.work.entity.Applicant;
import com.six.work.entity.CompanyAndPositionView;
import com.six.work.entity.Resume;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ResumeMapper {
    //企业登陆以后找人才
    @Select("select resume.*,post.* from resume join post on resume.applicant_id=post.applicant_id join company on post.company_id=company.company_id where company.company_id=#{company_id}")
    List<CompanyAndPositionView> findAllResumeByComID(Integer company_id);

    //企业找高校人才
    @Select("SELECT resume.*,post.* FROM resume join post on resume.applicant_id=post.applicant_id join company on post.company_id=company.company_id where company.company_id=#{company_id} and resume_university like '%${resume_university}%'")
    List<CompanyAndPositionView> findResByUniversity(@Param("resume_university")String resume_university,@Param("company_id") Integer company_id);

    //企业根据技术找人才
    @Select("SELECT resume.*,post.* FROM resume join post on resume.applicant_id=post.applicant_id join company on post.company_id=company.company_id where company.company_id=#{company_id} and resume_skill like '%${resume_skill}%'")
    List<CompanyAndPositionView> findResBySkill(@Param("resume_skill") String resume_skill,@Param("company_id") Integer company_id);

    //企业根据经历找人才
    @Select("SELECT resume.*,post.* FROM resume join post on resume.applicant_id=post.applicant_id join company on post.company_id=company.company_id where company.company_id=#{company_id} and resume_experience like '%${resume_experience}%'")
    List<CompanyAndPositionView> findResByExp(@Param("resume_experience") String resume_experience,@Param("company_id") Integer company_id);

    @Insert("insert into resume (resume_id,resume_name,resume_sex,resume_place,resume_university,resume_degree,resume_tel,resume_bg,resume_experience,resume_skill,resume_evalution,applicant_id) " +
            "values(#{resume_id}," +
            "#{resume_name},#{resume_sex},#{resume_place},#{resume_university},#{resume_degree},#{resume_tel},#{resume_bg},#{resume_experience},#{resume_skill},#{resume_evalution},#{applicant_id})")
    Integer insertResume(Resume resume);

    @Update("update resume set resume_id=#{resume_id},resume_name=#{resume_name},resume_sex=#{resume_sex},resume_place=#{resume_place},resume_university=#{resume_university},resume_degree=#{resume_degree},resume_tel=#{resume_tel},resume_bg=#{resume_bg},resume_experience=#{resume_experience},resume_skill=#{resume_skill},resume_evalution=#{resume_evalution} where applicant_id=#{applicant_id}")
    Integer updateResume(Resume resume);

    @Select("SELECT * from resume where applicant_id=#{applicant_id}")
    Resume SelectResumeByID(Integer applicant_id);

    //前端页面talent传值到postItemC
    @Select("SELECT * FROM resume where resume_id=#{resume_id}")
    List<Resume> SelectResByID(Integer resume_id);

    //求职者查看公司职位信息然后投递简历
    @Select("select * from resume where applicant_id=#{applicant_id}")
    List<Resume> findAllResumeByAppID(Integer applicant_id);




}
